#include <stdio.h>
#include <mysql.h>

int main(){
	int ret;
	int field_num;
	MYSQL_RES *result;
	MYSQL_ROW row_data;
	MYSQL *con=mysql_init(NULL);
	if( mysql_real_connect(con,"127.0.0.1","root","123abc//","test_db",\
			3306,NULL,0) == NULL ){
		printf("Connect error\n");
		return 0;
	}
	ret=mysql_query(con,"select * from tb_order");
	//ret=mysql_query(con,"select * from order_info");
	if(ret){
		printf("query error\n");
		return 0;
	}
	result=mysql_store_result(con);
	my_ulonglong num_rows=mysql_num_rows(result);
	//field_num=mysql_num_fields(result);
	printf("%llu rows\n",num_rows);
	if( mysql_fetch_row(result) ){
		printf("there's some data\n");
	}
	else{
		printf("thers's no data\n");
	}
	/*while( row_data=mysql_fetch_row(result) ){
		for(int i=0;i<field_num;i++){
			printf("%s ",row_data[i]);
		}
		printf("\n");
	}*/

	mysql_free_result(result);
	mysql_close(con);
	return 0;
}
